package grluApp;

import entity.Actor;
import entity.Movie;
import dao.ActorDao;
import dao.ArtistDao;
import dao.MovieDao;
import entity.Artist;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import view.MainWindow;

/**
 *
 * @author Javier
 */
public class Main {
    
    public static void main (String[] args){
        
        MainWindow mw = new MainWindow();
        mw.setVisible(true);
        
        Actor a = new Actor();
        ActorDao ac = new ActorDao();
        SimpleDateFormat sdt = new SimpleDateFormat("yyyy-MM-dd");
        Date date = null;
        try {
            date = sdt.parse("1966-09-09");
        } catch (ParseException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }
        a.setActBirthdate(date);
        a.setActBirthplace("Brooklyn");
        a.setActLastname("Sandler");
        a.setActName("Adam");
        a.setActPicture("http://upload.wikimedia.org/wikipedia/commons/thumb/0/09/Adam_Sandler_6818.jpg/200px-Adam_Sandler_6818.jpg");
        ac.persistActor(a);
        
        Actor b = new Actor();
        sdt = new SimpleDateFormat("yyyy-MM-dd");
        date = null;
        try {
            date = sdt.parse("1965-04-26");
        } catch (ParseException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }
        b.setActBirthdate(date);
        b.setActBirthplace("Mineola");
        b.setActLastname("James");
        b.setActName("Kevin");
        b.setActPicture("http://commons.wikimedia.org/wiki/File:Kevin-james-dickste-freunde-berlin-17-01-11.jpg");
        ac.persistActor(b);
        
        Actor c = new Actor();
        sdt = new SimpleDateFormat("yyyy-MM-dd");
        date = null;
        try {
            date = sdt.parse("1978-08-18");
        } catch (ParseException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }
        c.setActBirthdate(date);
        c.setActBirthplace("Mill Valley");
        c.setActLastname("Samberg");
        c.setActName("Andy");
        c.setActPicture("http://upload.wikimedia.org/wikipedia/commons/thumb/3/34/Andysamberg.jpg/200px-Andysamberg.jpg");
        ac.persistActor(c);
        
        Actor d = new Actor();
        sdt = new SimpleDateFormat("yyyy-MM-dd");
        date = null;
        try {
            date = sdt.parse("1990-08-15");
        } catch (ParseException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }
        d.setActBirthdate(date);
        d.setActBirthplace("Mill Valley");
        d.setActLastname("Lawrence");
        d.setActName("Jennifer");
        d.setActPicture("http://upload.wikimedia.org/wikipedia/commons/thumb/4/4f/Jennifer_Lawrence_at_the_83rd_Academy_Awards_crop.jpg/200px-Jennifer_Lawrence_at_the_83rd_Academy_Awards_crop.jpg");
        ac.persistActor(d);
        
        Actor e = new Actor();
        sdt = new SimpleDateFormat("yyyy-MM-dd");
        date = null;
        try {
            date = sdt.parse("1963-10-06");
        } catch (ParseException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }
        e.setActBirthdate(date);
        e.setActBirthplace("Louisiville");
        e.setActLastname("Shue");
        e.setActName("Elisabeth");
        e.setActPicture("http://commons.wikimedia.org/wiki/File:Elisabeth_Shue_at_the_2009_Tribeca_Film_Festival_2.jpg");
        ac.persistActor(e);
        
        MovieDao md = new MovieDao();
        Movie m = new Movie();
        //m.setActorCollection(col); // Si se deja esta linea, se agregan dos veces los actores
        m.setMovAvailableforpurchase(true);
        m.setMovAvailableforrental(true);
        m.setMovCover("http://www.imdb.com/media/rm2262673664/tt0837562");
        m.setMovDuration(91f);
        m.setMovGenre("Comedy");
        m.setMovName("Hotel Transylvania");
        m.setMovPlotkeywords("Animation,Comedy,Family");
        m.setMovRating(7.0f);
        m.setMovYear(2012);
        md.persistMovie(m);
        
        Movie m2 = new Movie();
        m2.setMovAvailableforpurchase(false);
        m2.setMovAvailableforrental(true);
        m2.setMovCover("http://ia.media-imdb.com/images/M/MV5BMjIxNTUwNTU4N15BMl5BanBnXkFtZTcwNTE0MTI3Nw@@._V1._SY317_.jpg");
        m2.setMovDuration(101f);
        m2.setMovGenre("Thriller");
        m2.setMovName("House at the End of the Street");
        m2.setMovPlotkeywords("Horror,Trhiller");
        m2.setMovRating(5.5f);
        m2.setMovYear(2012);
        md.persistMovie(m2);
        
        Movie m3 = new Movie();
        m3.setMovAvailableforpurchase(true);
        m3.setMovAvailableforrental(true);
        m3.setMovCover("http://ia.media-imdb.com/images/M/MV5BMTUwNjMyMzQ3M15BMl5BanBnXkFtZTcwMjcwNDMyOA@@._V1._SY317_CR0,0,214,317_.jpg");
        m3.setMovDuration(111f);
        m3.setMovGenre("Drama");
        m3.setMovName("Golpe de efecto");
        m3.setMovPlotkeywords("Drama");
        m3.setMovRating(6.5f);
        m3.setMovYear(2012);
        md.persistMovie(m3);
            
        ArtistDao ad = new ArtistDao();
        Artist s = new Artist();
        s.setArtBirthplace("Bogotá");
        s.setArtLastname("Rincón");
        s.setArtName("Santiago");
        s.setArtPicture("Foto");
        try {
            date = sdt.parse("1993-08-06");                  
        } catch (ParseException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }
        s.setArtBirthdate(date);
        ad.persistArtist(s);
        ad.deleteArtist(s);
    }
    
}
